//
//  YKAccount.m
//  youkan
//
//  Created by mac mini on 16/2/27.
//  Copyright © 2016年 Honsintech. All rights reserved.
//

#import "YKAccount.h"
#import "MJExtension.h"
@interface YKAccount()//<NSCoding>
@end
#define YKAccountTokeKey @"access_token"
#define YKExpires_inKey @"expires_in"
#define YKExpires_dateKey @"expires_date"
#define YKUidKey @"uid"
#define YKNameKey @"name"
@implementation YKAccount
MJCodingImplementation
-(void)setExpires_in:(NSString *)expires_in{
    _expires_in = expires_in;
    //    过期时间为当前保存时间+有效期
    _expires_date = [NSDate dateWithTimeIntervalSinceNow:[expires_in longLongValue]];
    YKLog(@"过期时间==%@",_expires_date);

}

+(instancetype)accountWithDictionary:(NSDictionary*)dic{
    YKAccount *account =[[self alloc]init];
//    YKLog(@"dic==%@",dic);
    [account setValuesForKeysWithDictionary:dic];
    return account;
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}
//          归档
//-(void)encodeWithCoder:(NSCoder *)aCoder{
//    [aCoder encodeObject:_access_token forKey:YKAccountTokeKey];
//    [aCoder encodeObject:_expires_in forKey:YKExpires_inKey];
//    [aCoder encodeObject:_uid forKey:YKUidKey];
//    [aCoder encodeObject:_expires_date forKey:YKExpires_dateKey];
//    [aCoder encodeObject:_name forKey:YKNameKey];
//}
//          解档
//-(id)initWithCoder:(NSCoder *)aDecoder{
//    if (self=[super init]) {
//        self.access_token =[aDecoder decodeObjectForKey:YKAccountTokeKey];
//        self.expires_in =[aDecoder decodeObjectForKey:YKExpires_inKey];
//        self.uid = [aDecoder decodeObjectForKey:YKUidKey];
//        self.expires_date =[aDecoder decodeObjectForKey:YKExpires_dateKey];
//        self.name =[aDecoder decodeObjectForKey:YKNameKey];
//    }
//    return self;
//}
@end
